package helper;

public abstract class StringUtils {
	// true if s matches to that pattern: ((-|\\+)?[0-9]+(\\.[0-9]+)?)+
	public static boolean isNumeric(String s) {
		if (s.matches("((-|\\+)?[0-9]+(\\.[0-9]+)?)+")) {
			return true;
		} else {
			return false;
		}
	}

	// true if s is an integer
	public static boolean isIntegral(String s) {
		return s.indexOf('.') == -1 && isNumeric(s);
	}

	// remove whitespaces
	public static String trim(String source) {
		return source.trim().replaceAll("\\s+", " ");
	}

	public static boolean isAlphaNumerical(String s) {
		if (s.matches("[a-zA-Z0-9_]+")) {
			return true;
		} else {
			return false;
		}
	}

}
